﻿using System;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;

namespace ModuloDeInventario
{
    public class Program
    {
        /// <summary>
        /// Punto de entrada principal para la aplicación.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Faprod());
        }

        public void ActualizarEntradas(int cod, int can)
        {
            Conexion cnn = new Conexion();
            SqlConnection cn = new SqlConnection(cnn.Conexionbd());

            SqlCommand cmd = new SqlCommand("PAEntradas", cn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@cod", cod);
            cmd.Parameters.AddWithValue("@can", can);

            try
            {
                cn.Open();
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            finally
            {
                cn.Dispose();
                cmd.Dispose();
            }
        }

        public void ActualizarSalidas(int cod, int can)
        {
            Conexion cnn = new Conexion();
            SqlConnection cn = new SqlConnection(cnn.Conexionbd());

            SqlCommand cmd = new SqlCommand("PASalidas", cn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@cod", cod);
            cmd.Parameters.AddWithValue("@can", can);

            try
            {
                cn.Open();
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            finally
            {
                cn.Dispose();
                cmd.Dispose();
            }
        }
    }
}
